#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
int main()
{
    int count = 0, year;
    for (int i = 1; i <= 5; i++)
    {
        cin >> year;
        int n = 1;
        int x = year;
        int a[5];
        while (x)
        {
            a[n++] = x % 10;
            x /= 10;
        }
        if (a[1] == a[3] + 1 && a[2] == a[4])
        {
            count++;
        }
    }
    cout << count;
    return 0;
}